//
//  DLMainTabBarController.swift
//  微博
//
//  Created by mac on 15/12/15.
//  Copyright © 2015年 mac. All rights reserved.
//

import UIKit

class DLMainTabBarController: UITabBarController
{



    override func viewDidLoad()
    {
        super.viewDidLoad()
        
//        let tabBar = UITabBar.appearance()
//        tabBar.tintColor = UIColor.orangeColor()
        
        //设置tabbar
        let mainTabBar = DLMainTabBar()
    
        self.setValue(mainTabBar, forKey: "tabBar")
        
        let homeVC = DLHomeViewController()
        addChildVC(homeVC, title:"首页", imageName:"tabbar_home")
        
        let messageVC = DLMessageViewController()
        addChildVC(messageVC, title: "消息", imageName: "tabbar_message_center")
        
        let discoverVC = DLDiscoverViewController()
        addChildVC(discoverVC, title: "发现", imageName: "tabbar_discover")
        
        let profileVC = DLProfileViewController()
        addChildVC(profileVC, title: "我", imageName: "tabbar_profile")
    }
    
    func addChildVC(childVC:UIViewController, title: String, imageName: String)
    {
        addChildViewController(UINavigationController(rootViewController: childVC));
        childVC.title = title;
        childVC.tabBarItem.setTitleTextAttributes([NSForegroundColorAttributeName : UIColor.orangeColor()], forState: UIControlState.Selected)
        childVC.tabBarItem.image = UIImage(named: imageName)
        
//        渲染颜色
        let hightlightImage = imageName + "_highlighted"
        childVC.tabBarItem.selectedImage = UIImage(named: hightlightImage)?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal)
    }
}
